package org.dulong.service.impl;

import org.dulong.dao.UserInfoDao;
import org.dulong.domain.UserInfo;
import org.dulong.service.UserInfoService;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-9-23
 * Time: 下午3:48
 * To change this template use File | Settings | File Templates.
 */
public class UserInfoServiceImpl implements UserInfoService {

    private UserInfoDao userInfoDao;

    public UserInfoDao getUserInfoDao() {
        return userInfoDao;
    }

    public void setUserInfoDao(UserInfoDao userInfoDao) {
        this.userInfoDao = userInfoDao;
    }

    @Override
    public void save(UserInfo userInfo) {
        if (userInfoDao.findByName(userInfo.getUsername()) == null) {
            throw new RuntimeException("该生:" + userInfo.getUsername() + "已经存在");
        }
        userInfoDao.save(userInfo);
    }
}
